<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <title><!--{$lang.page.index.title}--></title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/static/lay/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/static/lay/layui/index.css" media="all">
</head>
<body>

    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label"><!--{$lang.page.table.account}--></label>
                    <div class="layui-input-inline">
                        <input type="text" name="username" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label"><!--{$lang.page.table.starttime}--></label>
                    <div class="layui-input-block">
                      <input type="text" name="starttime" class="layui-input" id="startTime" placeholder="<!--{$lang.page.table.starttime}-->">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label"><!--{$lang.page.table.endtime}--></label>
                    <div class="layui-input-block">
                        <input type="text" name="endtime" class="layui-input" id="endTime" placeholder="<!--{$lang.page.table.endtime}-->">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label"><!--{$lang.page.table.status}--></label>
                    <div class="layui-input-inline">
                        <select name="status">
                            <option value=""><!--{$lang.page.public.select}--></option>
                            <option  value="1" ><!--{$lang.page.table.applying}--></option>
                            <option  value="2" ><!--{$lang.page.table.gback}--></option>
                            <option  value="3" ><!--{$lang.page.table.pass}--></option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="drawsearch">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </div>
        <div class="layui-card-body">      
            <table id="withdraw" lay-filter="withdraw"></table>
            <script type="text/html" id="toolbartop">
                <button class="layui-btn layui-btn-sm" lay-event="rewithdraw"><!--{$lang.page.public.refresh}--></button>
            </script>
            <script type="text/html" id="zizeng">{{d.LAY_TABLE_INDEX+1}}</script>
            <script type="text/html" id="withdrawtool">
                <a class="layui-btn layui-btn-xs draw" data-set="{{d.id}}"><!--{$lang.page.table.examine}--></a>
            </script>
        </div>
    </div>

<script src="/static/lay/layui/layui.js"></script>
<script type="text/javascript">
    layui.config({
       base: '/static/lay/' //静态资源所在路径
    }).extend({
         roleper:'lib/roleper'
         , xadmin:'lib/xadmin'
         , lang:'lib/lang'
       }).use(['roleper', 'xadmin', 'table', 'lang', 'laydate'], function () {

            var $ = layui.$
            , form = layui.form
            , table = layui.table
            , roleper = layui.roleper
            , toolbar = roleper.showtool({mid:33,per:[{sys:'draw'}]}) ? false : true; //根据权限是否显示操作列
            var laydate = layui.laydate;
            var lang=layui.lang.init();
            // 开始时间
            laydate.render({
              elem: '#startTime',
              type: 'datetime',
              max: 'now'
            });
            // 结束时间
            laydate.render({
              elem: '#endTime',
              type: 'datetime',
              min: '#startTime', // 设定最小日期为开始时间
              max: 'now'
            });
            table.render({
            elem: '#withdraw'
            , height: 'auto'
            , url: 'withdraw' //数据接口
            , method: 'post'
            , page: true //开启分页
            , limit: 10
            , toolbar: '#toolbartop'
            , defaultToolbar: ['filter', 'exports', 'print']
            , cols: [[ //表头
                {field: 'zizeng', title: function(){ return lang.serial }, align: "center", fixwidth: true, width: 80, templet:'#zizeng'},
                {field: 'username', title: function(){ return lang.account }},
                {field: 'realname', title: function(){ return lang.realname }},
                {field: 'type', title: function(){ return lang.class },
                 templet: function(d) {
                       if (d.type == 1) {
                            return '<button class="layui-btn layui-btn-green layui-btn-xs">'+lang.withdrawal+'</button>';
                        } else if(d.type == 2) {
                            return '<button class="layui-btn layui-btn-xs">'+lang.payment+'</button>';
                        } else if(d.type == 3) {
                            return '<button class="layui-btn layui-btn-danger layui-btn-xs">'+lang.cutpay+'</button>';
                        } else {
                            return '<button class="layui-btn layui-btn-primary layui-btn-xs">'+lang.error+'</button>';
                        }
                  }
                },
                {field: 'currency', title: function(){ return lang.withdrawal+lang.curtype }},
                {field: 'money', title: function(){ return lang.withdrawal+lang.money }},
                {field: 'fee', title: function(){ return lang.fee}},
                {field: 'payaction', title: function(){ return lang.payaction+lang.money },
                    templet: function(d) {
                       if (d.money > 0) {
                            return (d.money-d.fee);
                        } else{
                            return 0.00;
                        }
                    }
                },
                {field: 'codes', title: function(){ return lang.exchange+lang.curtype }},
                {field: 'remoney', title: function(){ return lang.exchange+lang.money},
                    templet: function(d) {
                       if (d.remoney > 0) {
                            return (d.remoney-d.fee*d.rate);
                        } else{
                            return 0.00;
                        }
                    }
                },
                {field: 'createtime', title: function(){ return lang.createtime}},
                {field: 'status', title: function(){ return lang.status},
                    templet: function(d) {
                       if (d.status == 1) {
                            return '<button class="layui-btn layui-btn-danger layui-btn-xs">'+lang.applying+'</button>';
                        } else if(d.status == 2) {
                            return '<button class="layui-btn layui-btn-primary layui-btn-xs">'+lang.gback+'</button>';
                        } else if(d.status == 3) {
                            return '<button class="layui-btn layui-btn-green layui-btn-xs">'+lang.pass+'</button>';
                        } else if(d.status == 4) {
                            return '<button class="layui-btn layui-btn-primary layui-btn-xs">'+lang.payready+'</button>';
                        }
                    }
                },
                {fixed: '', title: function(){ return lang.operation }, width: 160, align: 'center', toolbar: '#withdrawtool', hide:toolbar}
            ]],
            done: function() {
                layer.closeAll('loading');
                roleper.render({mid:33,per:[{sys:'draw',method:'open'}],full:false,law:'1380*550'});//law 设置长宽，full是否全屏，par父窗口打开
            }
            });

        form.on('submit(drawsearch)', function(data){
          var field = data.field;
          //执行重载
           table.reload('withdraw', {
            where: field
            ,page: {
              curr: 1 // 设定当前页为1
            }
           });
        });

        table.on('toolbar(withdraw)', function(obj){
            switch(obj.event){
                case 'rewithdraw':
                    //执行重载
                    table.reload('withdraw');
                break;
            };
        });     
    });
</script>
</body>
</html>

